<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要烧写裸机程序的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV04-02-GPIO-03-裸机程序烧写">
<meta property="og:url" content="https://sumumm.github.io/post/8cf1af4a.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要烧写裸机程序的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108070034143.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108071442966.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716203141888.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072116161.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072347405.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072517469.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072705491.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072800819.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074122472.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074514030.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074718879.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074854924.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108075212283.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108075318604.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108075852152.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108080128642.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108080335996.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108080627488.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716212636453.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108191248565.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108191446707.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716103844353.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716214922380.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215247142.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215423457.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215513838.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215956077.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20240117190003663.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20240117190017669.png">
<meta property="article:published_time" content="2024-11-08T12:59:34.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.038Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="(ALPHA)LV04-裸机开发">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108070034143.png">


<link rel="canonical" href="https://sumumm.github.io/post/8cf1af4a.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/8cf1af4a.html","path":"post/8cf1af4a.html","title":"LV04-02-GPIO-03-裸机程序烧写"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV04-02-GPIO-03-裸机程序烧写 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%A6%82%E8%BF%B0"><span class="nav-text">一、概述</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81imxdownload%E5%B7%A5%E5%85%B7"><span class="nav-text">二、imxdownload工具</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%B7%A5%E5%85%B7%E6%BA%90%E7%A0%81"><span class="nav-text">1. 工具源码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-imxdownload-c"><span class="nav-text">1.1 imxdownload.c</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-imxdownload-h"><span class="nav-text">1.2 imxdownload.h</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7"><span class="nav-text">2. 编译工具</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F"><span class="nav-text">3. 使用方式</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81mkimage%E5%B7%A5%E5%85%B7"><span class="nav-text">三、mkimage工具</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-uboot%E7%94%9F%E6%88%90%E7%9A%84imx%E6%96%87%E4%BB%B6"><span class="nav-text">1. uboot生成的imx文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-DCD%E6%95%B0%E6%8D%AE%E5%8E%BB%E5%93%AA%E9%87%8C%E6%89%BE%EF%BC%9F"><span class="nav-text">2. DCD数据去哪里找？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-mkimage"><span class="nav-text">2. mkimage</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E7%94%9F%E6%88%90-imx%E6%96%87%E4%BB%B6"><span class="nav-text">3. 生成.imx文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E5%AF%B9%E6%AF%94%E5%8C%BA%E5%88%AB"><span class="nav-text">4. 对比区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E7%83%A7%E5%86%99%E5%88%B0SD%E5%8D%A1"><span class="nav-text">5. 烧写到SD卡</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E7%BC%96%E8%AF%91mkimage"><span class="nav-text">6. 编译mkimage</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81mkImage-sh%E5%B7%A5%E5%85%B7"><span class="nav-text">四、mkImage.sh工具</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81%E7%83%A7%E5%86%99img%E6%96%87%E4%BB%B6%E5%88%B0SD%E5%8D%A1"><span class="nav-text">五、烧写img文件到SD卡</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-img%E6%96%87%E4%BB%B6"><span class="nav-text">1. img文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-1K%E5%AD%97%E8%8A%82%E7%9A%84%E7%A9%BA%E6%96%87%E4%BB%B6"><span class="nav-text">1.1 1K字节的空文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E7%94%9F%E6%88%90img%E6%96%87%E4%BB%B6"><span class="nav-text">1.2 生成img文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-windows%E4%B8%8B%E7%83%A7%E5%86%99img%E6%96%87%E4%BB%B6"><span class="nav-text">2. windows下烧写img文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-Win32DiskImager%E8%BD%AF%E4%BB%B6"><span class="nav-text">2.1 Win32DiskImager软件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E7%83%A7%E5%86%99img%E6%96%87%E4%BB%B6"><span class="nav-text">2.2 烧写img文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-ubuntu%E4%B8%8B%E7%83%A7%E5%86%99img%E6%96%87%E4%BB%B6"><span class="nav-text">3. ubuntu下烧写img文件</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AD%E3%80%81%E5%90%AF%E5%8A%A8%E6%B5%8B%E8%AF%95"><span class="nav-text">六、启动测试</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/8cf1af4a.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV04-02-GPIO-03-裸机程序烧写 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV04-02-GPIO-03-裸机程序烧写
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-11-08 20:59:34" itemprop="dateCreated datePublished" datetime="2024-11-08T20:59:34+08:00">2024-11-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/" itemprop="url" rel="index"><span itemprop="name">02IMX6ULL平台</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">LV04-裸机开发</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>7.5k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>27 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要烧写裸机程序的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows版本</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu版本</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>      </tr>    <tr>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="5">官方网站</td>        <td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td>        <td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/" target="_blank">https://www.nxp.com.cn/ </a></td>        <td align="left">NXP官方网站</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxpic.org.cn/" target="_blank">https://www.nxpic.org.cn/</a></td><td align="left">NXP 官方社区</td>    </tr>    <tr>        <td align="left"><a href="https://u-boot.readthedocs.io/en/latest/" target="_blank">https://u-boot.readthedocs.io/en/latest/</a></td><td align="left">u-boot官网</td>    </tr>    <tr>        <td align="left"><a href="https://www.kernel.org/" target="_blank">https://www.kernel.org/</a></td><td align="left">linux内核官网</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="4">NXP</td>        <td align="left"><a href="https://github.com/nxp-imx" target="_blank">https://github.com/nxp-imx</a></td>        <td align="left">NXP imx开发资源GitHub组织，里边会有u-boot和linux内核的仓库</td>    </tr>    <tr>        <td align="left"><a href="https://elixir.bootlin.com/linux/latest/source" target="_blank">https://elixir.bootlin.com/linux/latest/source</a></td>        <td align="left">在线阅读linux kernel源码</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP linux内核仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP u-boot仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="center" rowspan="2">I.MX6ULL</td>        <td align="left"><a href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLIEC.pdf" target="_blank">i.MX 6ULL Applications Processors for Industrial Products</a></td>        <td align="left">I.MX6ULL 芯片手册（datasheet，可以在线查看）</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/webapp/Download?colCode=IMX6ULLRM&lang_cd=zh" target="_blank">i.MX 6ULL Applications ProcessorReference Manual</a></td>        <td align="left">I.MX6ULL 参考手册（下载后才能查看，需要登录NXP官网）</td>    </tr></table>
              </div>
            </details>

<h1 id="一、概述"><a href="#一、概述" class="headerlink" title="一、概述"></a><font size=3>一、概述</font></h1><p>我们之前学习STM32的时候知道编译完代码以后可以直接通过 MDK 或者 IAR下载到内部的 flash 中，也就是内部的ROM。I.MX6ULL有内部ROM嘛？我们翻开芯片手册看一眼：<a target="_blank" rel="noopener" href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLCEC.pdf">i.MX 6ULL Applications Processors for Consumer Products (nxp.com.cn)</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108070034143.png" alt="image-20241108070034143" style="zoom:50%;" />

<p>我们看到内部有96KB的ROM和128KB的RAM，但是 I.MX6U 虽然内部有 96K 的 ROM，但是这 96K 的 ROM 是 NXP 自己用的，不向用户开放。所以相当于说 I.MX6ULL 是没有内部 flash 的，但是我们的代码得有地方存放啊，为此， I.MX6ULL 支持从外置的 NOR Flash、 NAND Flash、 SD&#x2F;EMMC、 SPI NOR Flash和 QSPI Flash 这些存储介质中启动，所以我们可以将代码烧写到这些存储介质中。</p>
<p>在这些存储介质中，除了 SD 卡以外，其他的一般都是焊接到了板子上的，我们没法直接烧写。但是 SD卡是活动的，是可以从板子上插拔的，我们可以将 SD 卡插到电脑上，在电脑上使用软件将 .bin 文件烧写到 SD 卡中，然后再插到板子上就可以了。其他的几种存储介质是我们量产的时候用到的，量产的时候代码就不可能放到 SD 卡里面了，毕竟 SD 是活动的，不牢固，而其他的都是焊接到板子上的，很牢固。  </p>
<p>因此，我们在调试裸机和 Uboot 的时候是将代码下载到 SD 中，因为方便嘛，当调试完成以后量产的时候要将裸机或者 u-boot 烧写到 SPI NOR Flash、 EMMC、 NAND 等这些存储介质中的。那么，如何将我们前面编译出来的 led.bin 烧写到 SD 卡中呢？</p>
<p>编译出来的可执行文件是怎么存放到 SD 中的，存放的位置是什么？这个 NXP 是有详细规定的！我们必须按照 NXP 的规定来将代码烧写到 SD 卡中，否则代码是绝对运行不起来的。《i.MX 6ULL Applications Processor Reference Manual》的第 8 章“Chapter 8 System Boot”就是专门讲解 I.MX6U 启动的，在前边我们已经学习过了。</p>
<p>接下来就来学习一下裸机程序烧写。</p>
<h1 id="二、imxdownload工具"><a href="#二、imxdownload工具" class="headerlink" title="二、imxdownload工具"></a><font size=3>二、imxdownload工具</font></h1><p>我们先来学习一下正点原子提供的这个imxdownload工具。</p>
<h2 id="1-工具源码"><a href="#1-工具源码" class="headerlink" title="1. 工具源码"></a><font size=3>1. 工具源码</font></h2><p>正点原子有提供源码的，路径在《阿尔法Linux开发板（A盘）-基础资料&#x2F;05、开发工具&#x2F;02、Ubuntu下裸机烧写软件》：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108071442966.png" alt="image-20241108071442966" style="zoom:50%;" />

<h3 id="1-1-imxdownload-c"><a href="#1-1-imxdownload-c" class="headerlink" title="1.1 imxdownload.c"></a><font size=3>1.1 imxdownload.c</font></h3><details class="folding-tag" blue><summary> 点击查看 imxdownload.c 源码 </summary>
              <div class='content'>
              <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;stdio.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;stdlib.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;string.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imxdownload.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> SHELLCMD_LEN	(200)</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> BIN_OFFSET		(3072)</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/* 此宏指明是否打印u-boot.imx的IVT DCD表信息，不同的开发板其IVT和DCD</span></span><br><span class="line"><span class="comment"> * 表的数据是不同的，因此需要获取所使用的开发板的IVT和DCD表信息，最</span></span><br><span class="line"><span class="comment"> * 简单的方法就是读取开发板配套资料里面的u-boot.imx的前1KB数据，理论上</span></span><br><span class="line"><span class="comment"> * 应该读取3KB的数据，但是表信息远远没有3K这么多，因此读1KB即可 </span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> PRINT_TAB		0	</span></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * 介绍： 此软件是针对NXP的IMX6U系列芯片的，软件用来烧写bin文件到SD卡里面，</span></span><br><span class="line"><span class="comment"> *        本软件会自动添加IVT、DCD等信息到原始的bin文件里面，主要用于裸机和uboot的烧写。</span></span><br><span class="line"><span class="comment"> * 使用方法： 1、编译好原始的二进制bin文件，如，u-boot.bin等，并将编译好的.bin文件和本</span></span><br><span class="line"><span class="comment"> *             软件放置到同一个目录下！！！！</span></span><br><span class="line"><span class="comment"> *        	2、执行命令sudo ./imxdownload &lt;soucre_bin&gt; &lt;sd_device&gt;</span></span><br><span class="line"><span class="comment"> *             如烧写u-boot.bin到/dev/sdd中即可使用如下所示命令:</span></span><br><span class="line"><span class="comment"> *             sudo ./imxdownload u-boot.bin /dev/sdd</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * 输出一些信息</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="type">void</span> <span class="title function_">message_print</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;	</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;I.MX6ULL bin download software\r\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Edit by:zuozhongkai\r\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Date:2019/6/10\r\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Version:V1.1\r\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;log:V1.0 initial version,just support 512MB DDR3\r\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;    V1.1 and support 256MB DDR3\r\n&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span> *argv[])</span></span><br><span class="line">&#123;</span><br><span class="line">	FILE *fp;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">char</span> *buf;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">char</span> *cmdbuf;</span><br><span class="line">	<span class="type">int</span> nbytes, filelen;</span><br><span class="line">	<span class="type">int</span> i = <span class="number">0</span>, j = <span class="number">0</span>;</span><br><span class="line">	<span class="type">int</span> ddrsize = <span class="number">0</span>; <span class="comment">/* 0为512MB，1为256MB，2为128MB...... */</span></span><br><span class="line"></span><br><span class="line">	message_print();</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span>((argc != <span class="number">3</span>) &amp;&amp; (argc != <span class="number">4</span>))&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;Error Usage! Reference Below:\r\n&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;sudo ./%s &lt;-512m or -256m&gt; &lt;source_bin&gt; &lt;sd_device&gt;\r\n&quot;</span>, argv[<span class="number">0</span>]);</span><br><span class="line">		<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* 查找参数，获取DDR容量 */</span></span><br><span class="line">	<span class="keyword">for</span>(i = <span class="number">0</span>; i &lt; argc; i++)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="type">char</span> *param = argv[i];</span><br><span class="line">		<span class="keyword">if</span>(param[<span class="number">0</span>] != <span class="string">&#x27;-&#x27;</span>)</span><br><span class="line">			<span class="keyword">continue</span>;</span><br><span class="line">		<span class="keyword">if</span>(<span class="built_in">strcmp</span>(param, <span class="string">&quot;-256m&quot;</span>) == <span class="number">0</span>) 		<span class="comment">/* 256MB */</span></span><br><span class="line">			ddrsize = <span class="number">1</span>;</span><br><span class="line">		<span class="keyword">else</span> <span class="keyword">if</span>(<span class="built_in">strcmp</span>(param, <span class="string">&quot;-512m&quot;</span>) == <span class="number">0</span>)	<span class="comment">/* 512MB */</span></span><br><span class="line">			ddrsize = <span class="number">0</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(argc == <span class="number">3</span>)	<span class="comment">/* 三个参数，也就是不输入DDR容量的话默认为512MB */</span></span><br><span class="line">		ddrsize = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* 打开bin文件 */</span></span><br><span class="line">	fp = fopen(argv[<span class="number">1</span>], <span class="string">&quot;rb&quot;</span>); <span class="comment">/* 以二进制只读方式打开bin文件 */</span></span><br><span class="line">	<span class="keyword">if</span>(fp == <span class="literal">NULL</span>)&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;Can&#x27;t Open file %s\r\n&quot;</span>, argv[<span class="number">1</span>]);</span><br><span class="line">		<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="comment">/* 获取bin文件长度 */</span></span><br><span class="line">	fseek(fp, <span class="number">0L</span>, SEEK_END);</span><br><span class="line">	filelen = ftell(fp);</span><br><span class="line">	fseek(fp, <span class="number">0L</span>, SEEK_SET);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;file %s size = %dBytes\r\n&quot;</span>, argv[<span class="number">1</span>], filelen);</span><br><span class="line">	</span><br><span class="line">	<span class="comment">/* 读取bin文件到缓冲区buf中 */</span></span><br><span class="line">	buf = <span class="built_in">malloc</span>(filelen + BIN_OFFSET);</span><br><span class="line">	<span class="keyword">if</span>(buf == <span class="literal">NULL</span>)&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;Mem Malloc Failed!\r\n&quot;</span>);</span><br><span class="line">		fclose(fp);</span><br><span class="line">		<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">memset</span>(buf, <span class="number">0</span>, filelen + BIN_OFFSET); <span class="comment">/* 清零 */</span></span><br><span class="line">	<span class="comment">/* 读取bin源码文件 */</span></span><br><span class="line">	fread(buf + BIN_OFFSET, <span class="number">1</span>, filelen, fp);</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* 关闭文件 */</span></span><br><span class="line">	fclose(fp);</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">if</span> PRINT_TAB</span></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;IVT DCD Table:\r\n&quot;</span>);</span><br><span class="line">	<span class="keyword">for</span>(i = <span class="number">0</span>; i &lt; <span class="number">1024</span>/<span class="number">32</span>; i++)&#123;</span><br><span class="line">		<span class="keyword">for</span>(j = <span class="number">0</span>; j &lt; <span class="number">8</span>; j++)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;0X%08X,&quot;</span>,*(<span class="type">int</span> *)(buf + BIN_OFFSET + (((i * <span class="number">8</span>) + j) * <span class="number">4</span>)));</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\r\n&quot;</span>);</span><br><span class="line">	&#125;	</span><br><span class="line">	<span class="built_in">free</span>(buf);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line">	</span><br><span class="line">	<span class="comment">/* 添加IVT DCD等表信息到bin文件里面 */</span></span><br><span class="line">	<span class="keyword">if</span>(ddrsize == <span class="number">0</span>) &#123;		<span class="comment">/* 512MB */</span></span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;Board DDR SIZE: 512MB\r\n&quot;</span>);</span><br><span class="line">		<span class="built_in">memcpy</span>(buf, imx6_512mb_ivtdcd_table, <span class="keyword">sizeof</span>(imx6_512mb_ivtdcd_table));</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">else</span> <span class="keyword">if</span> (ddrsize == <span class="number">1</span>) &#123;	<span class="comment">/* 256MB */</span></span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;Board DDR SIZE: 256MB\r\n&quot;</span>);</span><br><span class="line">		<span class="built_in">memcpy</span>(buf, imx6_256mb_ivtdcd_table, <span class="keyword">sizeof</span>(imx6_256mb_ivtdcd_table));</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* 现在我们已经在buf中构建好了可以用于下载的bin文件，将buf中的数据保存到</span></span><br><span class="line"><span class="comment">	 * 到一个文件中，文件命名为load.imx</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Delete Old load.imx\r\n&quot;</span>);</span><br><span class="line">	system(<span class="string">&quot;rm -rf load.imx&quot;</span>);		<span class="comment">/* 先删除旧的load.imx文件	*/</span></span><br><span class="line">	</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Create New load.imx\r\n&quot;</span>);</span><br><span class="line">	system(<span class="string">&quot;touch load.imx&quot;</span>);		<span class="comment">/* 创建新的load.imx文件		*/</span></span><br><span class="line">	fp = fopen(<span class="string">&quot;load.imx&quot;</span>, <span class="string">&quot;wb&quot;</span>);	<span class="comment">/* 打开laod.imx				*/</span></span><br><span class="line">	<span class="keyword">if</span>(fp == <span class="literal">NULL</span>)&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;Cant&#x27;t Open load.imx!!!\r\n&quot;</span>);</span><br><span class="line">		<span class="built_in">free</span>(buf);</span><br><span class="line">		<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	nbytes = fwrite(buf, <span class="number">1</span>, filelen + BIN_OFFSET, fp);</span><br><span class="line">	<span class="keyword">if</span>(nbytes != (filelen + BIN_OFFSET))&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;File Write Error!\r\n&quot;</span>);</span><br><span class="line">		<span class="built_in">free</span>(buf);</span><br><span class="line">		fclose(fp);</span><br><span class="line">		<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">free</span>(buf);</span><br><span class="line">	fclose(fp);	</span><br><span class="line">	</span><br><span class="line">	<span class="comment">/* 构建烧写的shell命令 */</span></span><br><span class="line">	cmdbuf = <span class="built_in">malloc</span>(SHELLCMD_LEN);</span><br><span class="line">	<span class="built_in">sprintf</span>(cmdbuf, <span class="string">&quot;sudo dd iflag=dsync oflag=dsync if=load.imx of=%s bs=512 seek=2&quot;</span>,argv[<span class="number">2</span>]);	</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Download load.imx to %s  ......\r\n&quot;</span>, argv[<span class="number">2</span>]);</span><br><span class="line">	</span><br><span class="line">	<span class="comment">/* 执行上面的shell命令 */</span></span><br><span class="line">	system(cmdbuf);</span><br><span class="line">	<span class="built_in">free</span>(cmdbuf);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;	</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="1-2-imxdownload-h"><a href="#1-2-imxdownload-h" class="headerlink" title="1.2 imxdownload.h"></a><font size=3>1.2 imxdownload.h</font></h3><p>这个文件里边的就是DCD信息，不同的芯片可能都是不一样的，需要注意。这个DCD信息我们其实可以去uboot源码中找，这后面学习另一个工具的时候会学习。</p>
<details class="folding-tag" blue><summary> 点击查看 imxdownload.h 文件 </summary>
              <div class='content'>
              <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifndef</span> _IMXDOWNLOAD_H</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> _IMXDOWNLOAD_H</span></span><br><span class="line"><span class="comment">/* IMX6U IVT DCD表信息  暂时定义为1K Bytes，此表是读取的u-boot.imx前1K Bytes</span></span><br><span class="line"><span class="comment"> * imx6_ivedcd_table[9]是指明代码长度的，本应该根据实际的代码长度来修改</span></span><br><span class="line"><span class="comment"> * 这里为了方便，就直接定义为2M Bytes，即</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="type">const</span> <span class="type">int</span> imx6_512mb_ivtdcd_table[<span class="number">256</span>] = &#123;</span><br><span class="line"><span class="number">0X402000D1</span>,<span class="number">0X87800000</span>,<span class="number">0X00000000</span>,<span class="number">0X877FF42C</span>,<span class="number">0X877FF420</span>,<span class="number">0X877FF400</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X877FF000</span>,<span class="number">0X00200000</span>,<span class="number">0X00000000</span>,<span class="number">0X40E801D2</span>,<span class="number">0X04E401CC</span>,<span class="number">0X68400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X6C400C02</span>,</span><br><span class="line"><span class="number">0XFFFFFFFF</span>,<span class="number">0X70400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X74400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X78400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X7C400C02</span>,</span><br><span class="line"><span class="number">0XFFFFFFFF</span>,<span class="number">0X80400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0XB4040E02</span>,<span class="number">0X00000C00</span>,<span class="number">0XAC040E02</span>,<span class="number">0X00000000</span>,<span class="number">0X7C020E02</span>,</span><br><span class="line"><span class="number">0X30000000</span>,<span class="number">0X50020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X4C020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X90040E02</span>,<span class="number">0X30000000</span>,<span class="number">0X88020E02</span>,</span><br><span class="line"><span class="number">0X30000C00</span>,<span class="number">0X70020E02</span>,<span class="number">0X00000000</span>,<span class="number">0X60020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X64020E02</span>,<span class="number">0X30000000</span>,<span class="number">0XA0040E02</span>,</span><br><span class="line"><span class="number">0X30000000</span>,<span class="number">0X94040E02</span>,<span class="number">0X00000200</span>,<span class="number">0X80020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X84020E02</span>,<span class="number">0X30000000</span>,<span class="number">0XB0040E02</span>,</span><br><span class="line"><span class="number">0X00000200</span>,<span class="number">0X98040E02</span>,<span class="number">0X30000000</span>,<span class="number">0XA4040E02</span>,<span class="number">0X30000000</span>,<span class="number">0X44020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X48020E02</span>,</span><br><span class="line"><span class="number">0X30000000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X00800000</span>,<span class="number">0X00081B02</span>,<span class="number">0X030039A1</span>,<span class="number">0X0C081B02</span>,<span class="number">0X0B000300</span>,<span class="number">0X3C081B02</span>,</span><br><span class="line"><span class="number">0X44014801</span>,<span class="number">0X48081B02</span>,<span class="number">0X302C4040</span>,<span class="number">0X50081B02</span>,<span class="number">0X343E4040</span>,<span class="number">0X1C081B02</span>,<span class="number">0X33333333</span>,<span class="number">0X20081B02</span>,</span><br><span class="line"><span class="number">0X33333333</span>,<span class="number">0X2C081B02</span>,<span class="number">0X333333F3</span>,<span class="number">0X30081B02</span>,<span class="number">0X333333F3</span>,<span class="number">0XC0081B02</span>,<span class="number">0X09409400</span>,<span class="number">0XB8081B02</span>,</span><br><span class="line"><span class="number">0X00080000</span>,<span class="number">0X04001B02</span>,<span class="number">0X2D000200</span>,<span class="number">0X08001B02</span>,<span class="number">0X3030331B</span>,<span class="number">0X0C001B02</span>,<span class="number">0XF3526B67</span>,<span class="number">0X10001B02</span>,</span><br><span class="line"><span class="number">0X630B6DB6</span>,<span class="number">0X14001B02</span>,<span class="number">0XDB00FF01</span>,<span class="number">0X18001B02</span>,<span class="number">0X40172000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X00800000</span>,<span class="number">0X2C001B02</span>,</span><br><span class="line"><span class="number">0XD2260000</span>,<span class="number">0X30001B02</span>,<span class="number">0X23106B00</span>,<span class="number">0X40001B02</span>,<span class="number">0X4F000000</span>,<span class="number">0X00001B02</span>,<span class="number">0X00001884</span>,<span class="number">0X90081B02</span>,</span><br><span class="line"><span class="number">0X00004000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X32800002</span>,<span class="number">0X1C001B02</span>,<span class="number">0X33800000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X31800400</span>,<span class="number">0X1C001B02</span>,</span><br><span class="line"><span class="number">0X30802015</span>,<span class="number">0X1C001B02</span>,<span class="number">0X40800004</span>,<span class="number">0X20001B02</span>,<span class="number">0X00080000</span>,<span class="number">0X18081B02</span>,<span class="number">0X27020000</span>,<span class="number">0X04001B02</span>,</span><br><span class="line"><span class="number">0X2D550200</span>,<span class="number">0X04041B02</span>,<span class="number">0X06100100</span>,<span class="number">0X1C001B02</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span></span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="type">const</span> <span class="type">int</span> imx6_256mb_ivtdcd_table[<span class="number">256</span>] = &#123;</span><br><span class="line"><span class="number">0X402000D1</span>,<span class="number">0X87800000</span>,<span class="number">0X00000000</span>,<span class="number">0X877FF42C</span>,<span class="number">0X877FF420</span>,<span class="number">0X877FF400</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X877FF000</span>,<span class="number">0X00076000</span>,<span class="number">0X00000000</span>,<span class="number">0X40E801D2</span>,<span class="number">0X04E401CC</span>,<span class="number">0X68400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X6C400C02</span>,</span><br><span class="line"><span class="number">0XFFFFFFFF</span>,<span class="number">0X70400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X74400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X78400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0X7C400C02</span>,</span><br><span class="line"><span class="number">0XFFFFFFFF</span>,<span class="number">0X80400C02</span>,<span class="number">0XFFFFFFFF</span>,<span class="number">0XB4040E02</span>,<span class="number">0X00000C00</span>,<span class="number">0XAC040E02</span>,<span class="number">0X00000000</span>,<span class="number">0X7C020E02</span>,</span><br><span class="line"><span class="number">0X30000000</span>,<span class="number">0X50020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X4C020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X90040E02</span>,<span class="number">0X30000000</span>,<span class="number">0X88020E02</span>,</span><br><span class="line"><span class="number">0X30000C00</span>,<span class="number">0X70020E02</span>,<span class="number">0X00000000</span>,<span class="number">0X60020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X64020E02</span>,<span class="number">0X30000000</span>,<span class="number">0XA0040E02</span>,</span><br><span class="line"><span class="number">0X30000000</span>,<span class="number">0X94040E02</span>,<span class="number">0X00000200</span>,<span class="number">0X80020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X84020E02</span>,<span class="number">0X30000000</span>,<span class="number">0XB0040E02</span>,</span><br><span class="line"><span class="number">0X00000200</span>,<span class="number">0X98040E02</span>,<span class="number">0X30000000</span>,<span class="number">0XA4040E02</span>,<span class="number">0X30000000</span>,<span class="number">0X44020E02</span>,<span class="number">0X30000000</span>,<span class="number">0X48020E02</span>,</span><br><span class="line"><span class="number">0X30000000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X00800000</span>,<span class="number">0X00081B02</span>,<span class="number">0X030039A1</span>,<span class="number">0X0C081B02</span>,<span class="number">0X04000000</span>,<span class="number">0X3C081B02</span>,</span><br><span class="line"><span class="number">0X3C013C01</span>,<span class="number">0X48081B02</span>,<span class="number">0X38324040</span>,<span class="number">0X50081B02</span>,<span class="number">0X28304040</span>,<span class="number">0X1C081B02</span>,<span class="number">0X33333333</span>,<span class="number">0X20081B02</span>,</span><br><span class="line"><span class="number">0X33333333</span>,<span class="number">0X2C081B02</span>,<span class="number">0X333333F3</span>,<span class="number">0X30081B02</span>,<span class="number">0X333333F3</span>,<span class="number">0XC0081B02</span>,<span class="number">0X09409400</span>,<span class="number">0XB8081B02</span>,</span><br><span class="line"><span class="number">0X00080000</span>,<span class="number">0X04001B02</span>,<span class="number">0X2D000200</span>,<span class="number">0X08001B02</span>,<span class="number">0X3030331B</span>,<span class="number">0X0C001B02</span>,<span class="number">0XF352433F</span>,<span class="number">0X10001B02</span>,</span><br><span class="line"><span class="number">0X630B6DB6</span>,<span class="number">0X14001B02</span>,<span class="number">0XDB00FF01</span>,<span class="number">0X18001B02</span>,<span class="number">0X40172000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X00800000</span>,<span class="number">0X2C001B02</span>,</span><br><span class="line"><span class="number">0XD2260000</span>,<span class="number">0X30001B02</span>,<span class="number">0X23104300</span>,<span class="number">0X40001B02</span>,<span class="number">0X47000000</span>,<span class="number">0X00001B02</span>,<span class="number">0X00001883</span>,<span class="number">0X90081B02</span>,</span><br><span class="line"><span class="number">0X00004000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X32800002</span>,<span class="number">0X1C001B02</span>,<span class="number">0X33800000</span>,<span class="number">0X1C001B02</span>,<span class="number">0X31800400</span>,<span class="number">0X1C001B02</span>,</span><br><span class="line"><span class="number">0X30802015</span>,<span class="number">0X1C001B02</span>,<span class="number">0X40800004</span>,<span class="number">0X20001B02</span>,<span class="number">0X00080000</span>,<span class="number">0X18081B02</span>,<span class="number">0X27020000</span>,<span class="number">0X04001B02</span>,</span><br><span class="line"><span class="number">0X2D550200</span>,<span class="number">0X04041B02</span>,<span class="number">0X06100100</span>,<span class="number">0X1C001B02</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line"><span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,<span class="number">0X00000000</span>,</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="2-编译工具"><a href="#2-编译工具" class="headerlink" title="2. 编译工具"></a><font size=3>2. 编译工具</font></h2><p>上边只是源码，我们想要使用的话，还需要进行编译，我们由于是在ubuntu中使用此工具，所以直接在ubuntu中使用gcc编译即可。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gcc imxdownload.c -o imxdownload -Wall</span><br></pre></td></tr></table></figure>

<p>然后我们就会得到一个 imxdownload 可执行文件，我们运行这个文件就可以将相应的uboot烧写到sd卡中。我们也可以写一个makefile文件来编译：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">TARGET      := imxdownload</span><br><span class="line">CC          := gcc</span><br><span class="line"></span><br><span class="line"><span class="variable">$(TARGET)</span>:imxdownload.c</span><br><span class="line">	gcc imxdownload.c -o <span class="variable">$(TARGET)</span></span><br><span class="line"></span><br><span class="line"><span class="meta"><span class="keyword">.PHONY</span>: clean</span></span><br><span class="line"><span class="section">clean: </span></span><br><span class="line">	rm -vf *.o <span class="variable">$(TARGET)</span></span><br></pre></td></tr></table></figure>

<h2 id="3-使用方式"><a href="#3-使用方式" class="headerlink" title="3. 使用方式"></a><font size=3>3. 使用方式</font></h2><p>我们之前已经生成好了led.bin文件，然后就是在ubuntu下降此文件烧写到sd卡中。我们可以执行以下命令查看一下SD卡在ubuntu中的节点：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo fdisk -l</span><br></pre></td></tr></table></figure>

<p>然后可以看到自己的SD卡的节点：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716203141888.png" alt="image-20230716203141888" style="zoom:50%;" />

<p>或者直接用这个命令看：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls /dev/sd*</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072116161.png" alt="image-20241108072116161" style="zoom: 67%;" />

<p>注意使用的是这个&#x2F;dev&#x2F;sdc节点，sdc1是SD卡的1分区，不要用这个。然后我们可以执行以下命令完成烧写：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./imxdownload &lt;.bin file&gt; &lt;SD Card&gt;</span><br></pre></td></tr></table></figure>

<p>在这里的话就是：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">../../tool/imxdownload/imxdownload led.bin /dev/sdc</span><br></pre></td></tr></table></figure>

<p>烧写的过程中可能会让输入密码，输入 ubuntu 密码即可完成烧写，烧写过程如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072347405.png" alt="image-20241108072347405" />

<p>烧写的最后一行会显示烧写大小、用时和速度，比如 led.bin 烧写到 SD 卡中的大小是 3.2KB，用时 0.15951s，烧写速度是 20.3 KB&#x2F;s。注意这个烧写速度，如果这个烧写速度在几百 KB&#x2F;s 以下那么就是正常烧写。如果这个烧写速度大于几十 MB&#x2F;s、甚至几百 MB&#x2F;s 那么肯定是烧写失败了！  这个时候我们会发现目录中多了一个imx文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072517469.png" alt="image-20241108072517469" />

<p>其实前面学习启动方式的时候学习过，imx文件会比bin文件多一些IVT等数据，我们可以看一下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072705491.png" alt="image-20241108072705491" />

<p>我们看一下开头就会发现链接地址：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108072800819.png" alt="image-20241108072800819" />

<p>解决方法就是重新插拔 SD 卡，一般出现这种情况，重新插拔 SD 卡基本没啥用，只有重启 ubuntu，至于原因嘛，不详。  </p>
<h1 id="三、mkimage工具"><a href="#三、mkimage工具" class="headerlink" title="三、mkimage工具"></a><font size=3>三、mkimage工具</font></h1><h2 id="1-uboot生成的imx文件"><a href="#1-uboot生成的imx文件" class="headerlink" title="1. uboot生成的imx文件"></a><font size=3>1. uboot生成的imx文件</font></h2><p>我们知道，生成了bin文件后，还需要将这个bin文件变为.imx文件，上边我们知道imxdownload这个工具可以直接将bin文件生成imx文件，然后烧写到sd卡中去，那不使用这个工具呢？其实也是有办法的。办法需要从u-boot中找，后边学习u-boot就会知道，编译u-boot的话，会生成bin文件，也会生成imx文件。我这里编译的是这个<a target="_blank" rel="noopener" href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.19.35_1.1.0">Release rel_imx_4.19.35_1.1.0: MLK-22866 imx8: Remove the optee shared memory from DDR banks · nxp-imx&#x2F;uboot-imx (github.com)</a>，编译完毕后如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074122472.png" alt="image-20241108074122472" />

<p>会发现上面会生成imx文件。这个文件我们就可以用于烧写到SD卡中。</p>
<h2 id="2-DCD数据去哪里找？"><a href="#2-DCD数据去哪里找？" class="headerlink" title="2. DCD数据去哪里找？"></a><font size=3>2. DCD数据去哪里找？</font></h2><p>前边学习映像文件的时候，有提到过这个DCD数据。那么这个DCD数据去哪找？我们去找一下怎么生成的imx文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074514030.png" alt="image-20241108074514030" />

<p>这个文件要编译完才有，先不管这个文件怎么来的以及原理，这里只看这个命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cmd_u-boot-dtb.imx := ./tools/mkimage -n u-boot-dtb.cfgout -T imximage -e 0x87800000 -d u-boot-dtb.bin u-boot-dtb.imx &gt;u-boot-dtb.imx.log </span><br></pre></td></tr></table></figure>

<p>大概分析一些可以知道是用了这个u-boot-dtb.cfgout，我们打开看一眼：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074718879.png" alt="image-20241108074718879" />

<p>其实这个文件就来源于imximage.cfg文件。这个文件在哪？ i.mx6ull的imximage.cfg 文件位于u-boot 源码的 board&#x2F;freescale&#x2F;mx6ullevk&#x2F; 目录下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108074854924.png" alt="image-20241108074854924" />

<p>这个imximage.cfg文件中就是厂家提供的DCD数据啦。会发现上面的u-boot-dtb.cfgout会比imximage.cfg多一些东西，但是这个DATA的行都是一样的：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108075212283.png" alt="image-20241108075212283" />

<h2 id="2-mkimage"><a href="#2-mkimage" class="headerlink" title="2. mkimage"></a><font size=3>2. mkimage</font></h2><p>这个工具的是u-boot编译完成后，会在tools目录下生成的，它的源码及可执行文件如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108075318604.png" alt="image-20241108075318604" />

<p>这个工具与具体的开发板无关，是u-boot的工具，所以这里可以直接拿来用。该工具的使用命令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./mkimage -n ./imximage.cfg -T imximage -e &lt;链接地址&gt; -d &lt;.bin文件&gt; &lt;.imx文件&gt;</span><br></pre></td></tr></table></figure>

<p>【注意】这里的链接地址要与生成bin文件的时候使用的链接地址一样。</p>
<h2 id="3-生成-imx文件"><a href="#3-生成-imx文件" class="headerlink" title="3. 生成.imx文件"></a><font size=3>3. 生成.imx文件</font></h2><p>我们拷贝上边的 imximage 工具和 board&#x2F;freescale&#x2F;mx6ullevk&#x2F;imximage.cfg 文件到我们的下载工具目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cp ~/7Linux/imx6ull-uboot/tools/mkimage* tool/mkimage/</span><br><span class="line">cp ~/7Linux/imx6ull-uboot/u-boot-dtb.cfgout tool/mkimage/</span><br><span class="line">cp ~/7Linux/imx6ull-uboot/board/freescale/mx6ullevk/imximage.cfg tool/mkimage/</span><br></pre></td></tr></table></figure>

<p>拷贝完后tool&#x2F;mkimage&#x2F;目录如下所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108075852152.png" alt="image-20241108075852152" />

<p>我们现在用u-boot中的工具imximage 试一下生成一个imx文件，命令格式是这样的：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./mkimage -n ./imximage.cfg -T imximage -e 0X87800000 -d led.bin led.imx</span><br></pre></td></tr></table></figure>

<p>按照我的目录结构，在这里应该是：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">../../tool/mkimage/mkimage -n ../../tool/mkimage/imximage.cfg -T imximage -e 0X87800000 -d led.bin led.imx</span><br></pre></td></tr></table></figure>

<p>额，然后就直接报错了：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108080128642.png" alt="image-20241108080128642" />

<p>怀疑是文件不对？其实刚才已经多拷贝了一个文件u-boot-dtb.cfgout，这个是编译uboot的时候，调用mkimage工具生成的imx文件的时候用的，里面会多一些东西，可能就是这些多的东西的原因，那我们呢直接用这个文件试一下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">../../tool/mkimage/mkimage -n ../../tool/mkimage/u-boot-dtb.cfgout -T imximage -e 0X87800000 -d led.bin led.imx</span><br></pre></td></tr></table></figure>

<p>然后就可以了：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108080335996.png" alt="image-20241108080335996" />

<p>其实数据还是那些，不过还有一些带#号的行出现，没有深究，就直接用就是了。</p>
<h2 id="4-对比区别"><a href="#4-对比区别" class="headerlink" title="4. 对比区别"></a><font size=3>4. 对比区别</font></h2><p>我们通过两种途径生成了imx文件，它们的IVT和DCD一样吗？我们用对比工具对比一下看看：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108080627488.png" alt="image-20241108080627488" />

<p>发现还是有一些不一样，可能是因为我用的新的uboot的原因吧，之前用的<a target="_blank" rel="noopener" href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga">Release rel_imx_4.1.15_2.1.0_ga: MLK-14707 fsl_esdhc: Fix eMMC 1.8v setting issue · nxp-imx&#x2F;uboot-imx (github.com)</a>这个版本，最后用这个工具生成的和正点原子的工具生成的是一样的：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716212636453.png" alt="image-20230716212636453"  />

<p>不过问题不大，可以直接烧写一下看 看能不能跑就知道了。烧写后会发现其实是一样的。</p>
<p>那有啥区别？区别就在于，正点原子提供给我们的imxdownload软件把链接地址写死为0x87800000，这意味着什么？这就意味着我们在后面编写链接脚本的时候只能用这个地址作为链接地址，我们的程序都将从这个地址开始存放，想修改怎么办？抱歉，没办法，除非修改imxdownload的源码，但是mkimage这个软件不一样，是在使用软件的时候指定了链接地址，这样我们就可以自定义啦。所以推荐还是用这个软件比较好。</p>
<h2 id="5-烧写到SD卡"><a href="#5-烧写到SD卡" class="headerlink" title="5. 烧写到SD卡"></a><font size=3>5. 烧写到SD卡</font></h2><p>上面我们只是生成了imx文件，这里我们还要烧写到SD卡中，我们可以使用以下命令烧写：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo dd if=led.imx of=/dev/sdc bs=1k seek=1 conv=fsync</span><br></pre></td></tr></table></figure>

<p>注意一定要加sudo，否则会提示权限不够。为什么要留1KB？前面学习映像文件的时候其实了解过了，从SD卡启动的时候，内部的boot ROM代码会从1KB的位置开始读，好像是因为我们常用的SD卡一个扇区的大小是512字节。前面两个扇区是不可以写入用户数据的，一般存的是SD卡相关的信息。而且imx6ull数据手册也写到SD&#x2F;EMMC启动是从地址偏移0x400字节的地方开始，所以这里不能直接覆盖。</p>
<p>我们会看到如下提示信息：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108191248565.png" alt="image-20241108191248565" />

<p>这样就烧写完毕了。</p>
<h2 id="6-编译mkimage"><a href="#6-编译mkimage" class="headerlink" title="6. 编译mkimage"></a><font size=3>6. 编译mkimage</font></h2><p>我们这里是有源码的，我们自己编译一下呢？Makefile如下：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">TARGET      := mkimage</span><br><span class="line">CC          := gcc</span><br><span class="line"></span><br><span class="line"><span class="variable">$(TARGET)</span>:mkimage.c</span><br><span class="line">	gcc mkimage.c -o <span class="variable">$(TARGET)</span></span><br><span class="line"></span><br><span class="line"><span class="meta"><span class="keyword">.PHONY</span>: clean</span></span><br><span class="line"><span class="section">clean: </span></span><br><span class="line">	rm -vf *.o <span class="variable">$(TARGET)</span></span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20241108191446707.png" alt="image-20241108191446707" />

<p>但是吧，报错了，看一眼，里面包含了不少的uboot内部的头文件，这里感觉没啥必要深究，就直接拿来用吧，以后有空再说。</p>
<h1 id="四、mkImage-sh工具"><a href="#四、mkImage-sh工具" class="headerlink" title="四、mkImage.sh工具"></a><font size=3>四、mkImage.sh工具</font></h1><p>这个其实是个脚本，这是NXP官方的SDK提供的，需要我们后面编译官方的SDK，所以后面学习到SDK的时候再来了解一下这种方式。可以看这里：《01嵌入式开发&#x2F;02IMX6ULL平台&#x2F;LV04-裸机开发&#x2F;LV04-03-BSP工程管理-01-NXP官方SDK.md》</p>
<h1 id="五、烧写img文件到SD卡"><a href="#五、烧写img文件到SD卡" class="headerlink" title="五、烧写img文件到SD卡"></a><font size=3>五、烧写img文件到SD卡</font></h1><p>上边我们通过正点原子的imxdownload工具直接在ubuntu下完成imx文件的生成和烧写，那我们现在有一个imx文件，怎么办？回到bin文件？肯定不是啦，在ubuntu和windows下都有烧写的办法，这一节就来了解一下如何将imx文件烧写到sd卡中吧。</p>
<h2 id="1-img文件"><a href="#1-img文件" class="headerlink" title="1. img文件"></a><font size=3>1. img文件</font></h2><h3 id="1-1-1K字节的空文件"><a href="#1-1-1K字节的空文件" class="headerlink" title="1.1 1K字节的空文件"></a><font size=3>1.1 1K字节的空文件</font></h3><p>为什么要有一个1K字节的空文件？原因就在于这个IVT，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716103844353.png" alt="image-20230716103844353" style="zoom:50%;" />

<p>IVT的偏移的话，在sd卡中，mmc都需要偏移1KB，而我们生成的imx文件，IVT直接从0开始，所以需要制作一个IVT偏移了1K的文件。我们在ubuntu编译好了imx文件后，可以先做一个1K字节的空文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dd if=/dev/zero of=1k.bin bs=1024 count=1</span><br></pre></td></tr></table></figure>

<p>dd命令 可从标准输入或文件中读取数据，根据指定的格式来转换数据，再输出到文件、设备或标准输出。上边的命令含义就是以&#x2F;dev&#x2F;zero作为输入文件，1k.bin作为输出文件，同时设置读入&#x2F;输出的块大小为1024个字节（1KB），仅拷贝1个块。这样我们就会生成一个1KB的1k.bin文件啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716214922380.png" alt="image-20230716214922380" style="zoom:50%;" />

<h3 id="1-2-生成img文件"><a href="#1-2-生成img文件" class="headerlink" title="1.2 生成img文件"></a><font size=3>1.2 生成img文件</font></h3><p>接下来将imx文件和1k.bin文件合并起来，注意1k.bin文件要在前，这样才能保证生成的img文件的IVT在1K的偏移处：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat 1k.bin led.imx &gt; led.img</span><br></pre></td></tr></table></figure>

<h2 id="2-windows下烧写img文件"><a href="#2-windows下烧写img文件" class="headerlink" title="2. windows下烧写img文件"></a><font size=3>2. windows下烧写img文件</font></h2><h3 id="2-1-Win32DiskImager软件"><a href="#2-1-Win32DiskImager软件" class="headerlink" title="2.1 Win32DiskImager软件"></a><font size=3>2.1 Win32DiskImager软件</font></h3><p>我们需要借助Win32DiskImager这个软件来吧img文件写入到sd卡中去，我们可以在这里下载这个软件：<a target="_blank" rel="noopener" href="https://sourceforge.net/projects/win32diskimager/">Win32 Disk Imager download | SourceForge.net</a>，这个软件安装一路默认就好了，打开如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215247142.png" alt="image-20230716215247142" style="zoom:50%;" />

<h3 id="2-2-烧写img文件"><a href="#2-2-烧写img文件" class="headerlink" title="2.2 烧写img文件"></a><font size=3>2.2 烧写img文件</font></h3><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215423457.png" alt="image-20230716215423457" style="zoom:50%;" />

<p>如上图所示：【选择img文件】&rarr;【选中要烧写的sd卡盘符】&rarr;【写入】，写入完成则会有以下提示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215513838.png" alt="image-20230716215513838" style="zoom:50%;" />

<p>然后点击OK，再退出即可。</p>
<h2 id="3-ubuntu下烧写img文件"><a href="#3-ubuntu下烧写img文件" class="headerlink" title="3. ubuntu下烧写img文件"></a><font size=3>3. ubuntu下烧写img文件</font></h2><p>ubuntu下的话，可以使用dd命令，使用该命令我们甚至可以不需要1k的哪个空文件，直接通过这个命令将imx文件烧写到sd卡挂载节点的1k处：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo dd if=led.imx of=/dev/sdc bs=1k seek=1 conv=fsync</span><br></pre></td></tr></table></figure>

<p>烧写完成会有如下提示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20230716215956077.png" alt="image-20230716215956077" style="zoom:50%;" />

<p>除了上面的命令，我们还可以使用正点原子提供的哪个烧写工具，那个其实也一样的，只是它是通过c语言的system函数来执行了dd这个shell命令。如果想要烧img文件，直接dd命令不偏移就可以了，不过还是直接烧到1KB处方便，毕竟少生成一个文件。</p>
<h1 id="六、启动测试"><a href="#六、启动测试" class="headerlink" title="六、启动测试"></a><font size=3>六、启动测试</font></h1><p>代码已经烧写到了 SD 卡中了，接下来就是将 SD 卡插到开发板的 SD 卡槽中，然后设置拨码开关为 SD 卡启动，拨码开关设置如图 ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20240117190003663.png" alt="image-20240117190003663" style="zoom:33%;" />

<p>设置好以后按一下开发板的复位键，如果代码运行正常的话 LED0 就会被点亮 ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/LV04-02-GPIO-03-%E8%A3%B8%E6%9C%BA%E7%A8%8B%E5%BA%8F%E7%83%A7%E5%86%99/img/image-20240117190017669.png" alt="image-20240117190017669" style="zoom:32%;" />

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/8cf1af4a.html">LV04-02-GPIO-03-裸机程序烧写</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年11月08日 - 20:59</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/8cf1af4a.html" title="LV04-02-GPIO-03-裸机程序烧写">https://sumumm.github.io/post/8cf1af4a.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/ALPHA-LV04-%E8%A3%B8%E6%9C%BA%E5%BC%80%E5%8F%91/" rel="tag"><i class="fa fa-tag"></i> (ALPHA)LV04-裸机开发</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/87e9a534.html" rel="prev" title="LV04-02-GPIO-04-C语言下的GPIO操作">
                  <i class="fa fa-angle-left"></i> LV04-02-GPIO-04-C语言下的GPIO操作
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/35c09a55.html" rel="next" title="LV04-02-GPIO-02-汇编点亮LED灯">
                  LV04-02-GPIO-02-汇编点亮LED灯 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
